package com.gopay.bis.dao.payconfig.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.gopay.bis.dao.payconfig.BisExpayDtlDAO;
import com.gopay.common.base.dao.impl.BaseDAOImpl;
import com.gopay.common.domain.bank.BisBankExpayDtl;

/** 
 * 快捷流水DAO实现
 * @ClassName: BisExpayDtlDAOImpl 
 * @author w_jiqing 
 * @date 2017年2月10日 下午1:26:37  
 */ 
@Repository("bisExpayDtlDAO")
public class BisExpayDtlDAOImpl extends BaseDAOImpl<BisBankExpayDtl, Integer> implements BisExpayDtlDAO{


    @Override
    public BisBankExpayDtl getBisExpayDtl(String orderId) {
        String hql = "from BisBankExpayDtl where orderId = :orderId order by createdTime desc";
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("orderId", orderId);
        List<BisBankExpayDtl> list  = findByHql(hql, params);
        if(null == list || list.isEmpty()){
            return null;
        }
        return list.get(0);
    }

    @Override
    public List<BisBankExpayDtl> getBisExpayDtlList(String orderId, String status) {
        String hql = "from BisBankExpayDtl where orderId = :orderId and orderStatus = :status ";
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("orderId", orderId);
        params.put("status", status);
        List<BisBankExpayDtl> list  = findByHql(hql, params);
        return list;
    }

    @Override
    public List<BisBankExpayDtl> getBisExpayDtlList(String orderId, String elements, String status) {
        String hql = "from BisBankExpayDtl where orderId = :orderId and elementsValue = :elementsValue and orderStatus = :status ";
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("orderId", orderId);
        params.put("elementsValue", elements);
        params.put("status", status);
        List<BisBankExpayDtl> list  = findByHql(hql, params);
        return list;
    }

}
